/*
 * $Id: DefaultFormatterFactory.java 39 2012-12-28 12:55:42Z vladimirow@mail.ru $
 * $HeadURL: http://ultralog.googlecode.com/svn/ultralog/tags/release-20130123/src/java/com/google/code/ultralog/formatter/def/DefaultFormatterFactory.java $
 *
 * This file is a part of ultralog project (http://code.google.com/p/ultralog/).
 * Released under New BSD License.
 */
package com.google.code.ultralog.formatter.def;

import com.google.code.ultralog.formatter.BooleanFormatter;
import com.google.code.ultralog.formatter.ByteFormatter;
import com.google.code.ultralog.formatter.CharacterFormatter;
import com.google.code.ultralog.formatter.DoubleFormatter;
import com.google.code.ultralog.formatter.FloatFormatter;
import com.google.code.ultralog.formatter.FormatterFactory;
import com.google.code.ultralog.formatter.IntegerFormatter;
import com.google.code.ultralog.formatter.LongFormatter;
import com.google.code.ultralog.formatter.ReferenceFormatter;
import com.google.code.ultralog.formatter.ShortFormatter;

/**
 * Default implementation of {@link FormatterFactory} interface.
 *
 * @author Mikhail Vladimirov
 */
public class DefaultFormatterFactory implements FormatterFactory
{
    /**
     * Singleton instance of the factory.
     */
    public final static DefaultFormatterFactory INSTANCE =
        new DefaultFormatterFactory ();

    private DefaultFormatterFactory ()
    {
        // Do nothing
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BooleanFormatter createBooleanFormatter (String options)
    {
        if (options == null)
            throw new IllegalArgumentException ("Options is null");

        if (!"".equals (options))
            throw new IllegalArgumentException (
                "Unsupported options: " + options);

        return DefaultBooleanFormatter.INSTANCE;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public ByteFormatter createByteFormatter (String options)
    {
        if (options == null)
            throw new IllegalArgumentException ("Options is null");

        if (!"".equals (options))
            throw new IllegalArgumentException (
                "Unsupported options: " + options);

        return DefaultByteFormatter.INSTANCE;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public ShortFormatter createShortFormatter (String options)
    {
        if (options == null)
            throw new IllegalArgumentException ("Options is null");

        if (!"".equals (options))
            throw new IllegalArgumentException (
                "Unsupported options: " + options);

        return DefaultShortFormatter.INSTANCE;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public CharacterFormatter createCharacterFormatter (String options)
    {
        if (options == null)
            throw new IllegalArgumentException ("Options is null");

        if (!"".equals (options))
            throw new IllegalArgumentException (
                "Unsupported options: " + options);

        return DefaultCharacterFormatter.INSTANCE;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public IntegerFormatter createIntegerFormatter (String options)
    {
        if (options == null)
            throw new IllegalArgumentException ("Options is null");

        if (!"".equals (options))
            throw new IllegalArgumentException (
                "Unsupported options: " + options);

        return DefaultIntegerFormatter.INSTANCE;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public LongFormatter createLongFormatter (String options)
    {
        if (options == null)
            throw new IllegalArgumentException ("Options is null");

        if (!"".equals (options))
            throw new IllegalArgumentException (
                "Unsupported options: " + options);

        return DefaultLongFormatter.INSTANCE;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public FloatFormatter createFloatFormatter (String options)
    {
        if (options == null)
            throw new IllegalArgumentException ("Options is null");

        if (!"".equals (options))
            throw new IllegalArgumentException (
                "Unsupported options: " + options);

        return DefaultFloatFormatter.INSTANCE;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public DoubleFormatter createDoubleFormatter (String options)
    {
        if (options == null)
            throw new IllegalArgumentException ("Options is null");

        if (!"".equals (options))
            throw new IllegalArgumentException (
                "Unsupported options: " + options);

        return DefaultDoubleFormatter.INSTANCE;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public <T> ReferenceFormatter <? super T> createReferenceFormatter (
            Class <T> type, String options)
    {
        if (type == null)
            throw new IllegalArgumentException ("Type is null");

        if (options == null)
            throw new IllegalArgumentException ("Options is null");

        if (!"".equals (options))
            throw new IllegalArgumentException (
                "Unsupported options: " + options);

        return DefaultReferenceFormatter.INSTANCE;
    }
}
